package com.microservice.skeleton.resource.controller;

import com.auth0.jwt.JWT;
import com.auth0.jwt.impl.JWTParser;
import com.auth0.jwt.interfaces.DecodedJWT;
import com.microservice.skeleton.common.vo.AccessToken;
import com.microservice.skeleton.resource.client.UpmsClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Mr.Yangxiufeng on 2017/12/29.
 * Time:9:23
 * ProjectName:Mirco-Service-Skeleton
 */
@RestController
public class UserController {

    @Autowired
    private UpmsClient upmsClient;

    @GetMapping(value = "getUser")
    public String getUser(HttpServletRequest request, @AccessToken String accessToken){
        DecodedJWT decode = JWT.decode(accessToken);
        System.out.println(decode.toString());
        return upmsClient.getRoleByUserId(46);
    }

}
